describe('practice-5-4', function () {

    it("找出四位数中所有的可逆素数", function () {
        var arr_result = get_reversible_prime();
        for(var i = 0; i < arr_result.length; i ++)
        {
            var prime = arr_result[i];
            expect(fun(prime)).toBe(1);
            var reversible = prime.toString();
            var a = parseInt(reversible.substr(0,1),0);
            var b = parseInt(reversible.substr(1,1),0);
            var c = parseInt(reversible.substr(2,1),0);
            var d = parseInt(reversible.substr(3,1),0);
            expect(fun(a+b*10+c*100+d*1000)).toBe(1);
        }
    });

});
function fun(i)
{
    if(i===2)
        return 1;
    if(0===(i%2))
        return 0;
    for(var j = 3;j <=Math.sqrt(i);j+=2)
    {
        if(0===(i%j)) return 0;
    }
    return 1;
}